from docx import Document

def read_word_file(file_path):
    # 加载文档
    doc = Document(file_path)
    text = []

    for table in doc.tables:
        for row in table.rows:
            for cell in row.cells:
                print(cell.text,end=' ')
            print()
        print("------ 分隔符 ------") 

    # 遍历文档中的每个段落
    for para in doc.paragraphs:
        text.append(para.text)

    return '\n'.join(text)

if __name__ == '__main__' :
    file_path = r'C:/Users/18210/Desktop/read_docx.docx'
    content = read_word_file(file_path)
    print(content)
